load-module
Node's require
with a few extra features:
- You can specify additional folders in which to search for modules
- You can specify a module prefix
Example
> const loadModule = require('load-module')
> loadModule('react-dom')
> loadModule('dom', { prefix: 'react-' })
> loadModule('something.js', { paths: '.' })
> loadModule('something.js', { paths: [ '.', '~/my-modules' ] })
loadModule(request, [options]) ⏏
Kind: Exported function
Param | Type | Description |
---|
request | string | The module name, directory or file to load. |
[options] | object | |
[options.paths] | string | Array.<string> | One or more additional directories in which to search for modules. For each path specified, both the path itself and ${path}/node_modules will be searched. |
[options.prefix] | string | Attempt to load the given module name with this prefix. Only useful where request is a module name. |
© 2017-19
Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.